Categories
PHP WordPress

WordPress memory exhausted error

If you were activating a huge plugin and found an error that says memory exhausted just add the following line of code to your wp-config.php file.

define('WP_MEMORY_LIMIT', '64M');

The above code will increase the memory limit to 64M, but you can change the value to whatever your hosting server is able to support.

Categories
WordPress

Add settings fields on options discussion admin page

You have to call add_settings_section() first, pass a unique ID and assign it to the page (poor name) discussion:

add_settings_section( 'ads_id', 'Extra Settings', 'ads_description', 'discussion' );

Then register a callback to save your field(s) …

// Register a callback
register_setting(
    'discussion',
    'ads',
    'trim'
);

… and then register one or more fields:

// Register the field for the "avatars" section.
add_settings_field(
    'ads',
    'Test field',
    'ads_show_settings',
    'discussion',
    'ads_id',
    array ( 'label_for' => 'ads_id' )
);

Here is a very simple example:

add_action( 'admin_init', 'ads_register_setting' );

/**
 * Tell WP we use a setting - and where.
 */
function ads_register_setting()
{
    add_settings_section(
        'ads_id',
        'Extra Settings',
        'ads_description',
        'discussion'
    );

    // Register a callback
    register_setting(
        'discussion',
        'ads',
        'trim'
    );
    // Register the field for the "avatars" section.
    add_settings_field(
        'ads',
        'Test field',
        'ads_show_settings',
        'discussion',
        'ads_id',
        array ( 'label_for' => 'ads_id' )
    );
}

/**
 * Print the text before our field.
 */
function ads_description()
{
    ?><p class="description">This is the description</p><?php
}

/**
 * Show our field.
 *
 * @param array $args
 */
function ads_show_settings( $args )
{
    $data = esc_attr( get_option( 'ads', '' ) );

    printf(
        '<input type="text" name="ads" value="%1$s" id="%2$s" />',
        $data,
        $args['label_for']
    );
}
Categories
MailChimp WordPress

MailChimp Get all subscribers emails from a list

WooCommerce
Categories
WordPress

How to Change the Login Logo in WordPress

Categories
WooCommerce

How to Change the Login Logo URL in WordPress

Categories
BuddyPress WordPress

BuddyPress how to check friendship status of two users.

$member_friend_status = friends_check_friendship_status( $user1, $user2 );
Categories
BuddyPress WordPress

How to get member id in BuddyPress member loop

$member_id = bp_get_member_user_id();