WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
Login Status (12 posts)

  1. bk_design
    Member
    Posted 2 years ago #

    Hi Chad,

    I just noticed that after I made the last update.

    <?php wpmem_login_status(); ?>

    Doesn't display the username. It says "You are logged in as wp-members". I am not sure why this is happening. It worked before.

    Thanks,
    Brad

  2. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    wpmem_login status echos the result of wpmem_inc_status found in wp-members.php. The function is right at the top of that file and the problem is in that function. I'm not sure how this got missed, but when I converted the plugin for localization, the string and the plugin name are transposed .

    sprintf(__('You are logged in as %s', $user_login), 'wp-members')

    should be:

    sprintf(__('You are logged in as %s', 'wp-members'), $user_login)

    <insert head slap here>

  3. bk_design
    Member
    Posted 2 years ago #

    Hi Chad,

    Thank you so much but I think you meant to make that change in the wp-members-sidebar.php file? That is what I updated and it works now.

    I also had one more question:

    Is there anyway to add titles to a group of questions on the register form and exclude them when you export the group of wp-members? I have a series of questions and I am grouping them together in segments. I was able to create a custom array for each specific title. My only issue is that when I export the group of wp-members so does the titles. Is there away to exclude those?

    Thanks,
    Brad

  4. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    Ahhh, yes, I did mean wp-members-sidebar.php. Glad you got that figured out :-)

    On the other question, if I understand correctly, you are talking about the csv export process? If so, your only real solution there is to customize the wp-members-export.php (there - I got that one right!) You would need to customize the loop and work in conditional statements that if true, skip appending the field.

    Essentially, there is a loop within a loop. It begins by grabbing the array of users it will export and loops through that.

    foreach ($user_arr as $user) {

    Within that, it loops through the array of $wpmem_fields starting at:

    for ($row = 0; $row < count($wpmem_fields); $row++) {

    It does some logical tests (i.e. if the field is used or not) and appends that to $data. I would work in a condition that if $wpmem_fields[$row][2] (the name of the field) is the title, then skip over it - or something like that.

    Hope that gives you something to go on...

  5. bk_design
    Member
    Posted 2 years ago #

    Hi Chad,

    Thanks for writing me back. I am pretty new to PHP I am not certain if I have this correct. But what I am trying to say is that row 5 should not export. This is what I have but not sure if it is even close to correct:

    $hrow = "User ID,Username,";
    for ($row = 0; $row < count($wpmem_fields); $row++) {
    	if ($wpmem_fields[$row][4] == 'y') {
    		$hrow.= $wpmem_fields[$row][1].",";
    	}
    }
    if ($wpmem_fields[$row][5] == 'n');

    Thanks,
    Brad

  6. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    You're on the right track, but we need to clarify a few things.

    This section is looping through the array of fields. Each field represents an array containing the following: order, field label, field name, type, display, required, native. So this is a multidimensional array, or an array containing arrays.

    The line for ($row = 0; $row < count($wpmem_fields); $row++) { indicates that we are going to loop through each of these beginning at 0 (the first row). For each row in the fields array that we go through, we will increment by 1. So the row number we are on is indicated by $row.

    The number you see is the column number in the field array. That is the list that I indicated before: order, field label, field name, type, display, required, native.

    If your group titles are in the array of fields, then you want to skip that row (not column). (Note: your use of "5" is a column, and starting with zero, your condition says if, for each field row, the "required" column is "n"... I don' think that's what you want.) So, what you want is probably more like this:

    if ( $wpmem_fields[$row][2] == 'my-value' ) {
    ...rest of the action...
    }

    In this case, 'my-value' would be whatever you have named the fieldname column for what you want to skip (remember, we start at 0, so it's the third column). You could also use columns 0 or 1, just change what they should be value-wise.

    Thinking this through, you're actually going to probably want to test that it is NOT equal to, then continue, so instead of == (equal to), use != (not equal to).

    Last thing to mention that brings this all together is that you want to do this before the value is appended to $hrow. $hrow is building the data to export, so this is stuff you want to leave out, so you want to make sure you skip it before it appends ($hrow.= $wpmem_fields[$row][1].",";

    So you should end up with something like this (with comments):

    // start looping through the array of fields
    for ($row = 0; $row < count($wpmem_fields); $row++) {
    
    	// check for fieldname 'whats-your-value'
    	if ($wpmem_fields[$row][2] != 'whats-your-value');
    
    		// check to see if field is actually used (displayed)
    		if ($wpmem_fields[$row][4] == 'y') {
    
    			// all checks out, append the data to $hrow
    			$hrow.= $wpmem_fields[$row][1].",";
    
    		} // closes your check for column 5
    
    	} // closes your check for column 3
    
    } // if not done, do next row

    Hope that clarifies things a little.

  7. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    Actually, I wrote the above without actually looking at the entire function. The above will build your header row (hence $hrow). You need to do this check twice, the second being where it builds the data, which is inside of the loop:

    // build the data, delimit by commas, use \n switch for new line
    foreach ($user_arr as $user) {

    So the beginning of that process is where you would check for what to skip, which would be something like:

    $user_info = get_userdata($user);
    
     $data.= $user_info->ID.",".$user_info->user_login.",";
    
    for ($row = 0; $row < count($wpmem_fields); $row++) {
    
    	// check for what your are skipping, just like before
    	if ($wpmem_fields[$row][2] != 'whats-your-value');
    
    		if ($wpmem_fields[$row][4] == 'y') {
    
    			if ($wpmem_fields[$row][2] == 'user_email') {
    
    				$data.= $user_info->user_email.",";
    
    			} else {
    
    				$data.= get_user_meta($user, $wpmem_fields[$row][2], true).",";
    
    			}
    		}
    
    	} // this closes your check for 'whats-your-value'
    }
  8. bk_design
    Member
    Posted 2 years ago #

    Hi Chad,

    Thank you so much for responding. I tried to piece the code together and the column "whats-your-value" is still exporting. Yes I am changing 'whats-your-value' to the fieldname of the column. Which is actually 'Accounting Information'

    Here is a link to the code:
    http://pastebin.com/YsbyN5NQ

  9. bk_design
    Member
    Posted 2 years ago #


  10. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    The field name would generally be something with no spaces (although I understand you aren't really using these as an actual field so maybe it can...). If that's the field "label," it would be the previous column, in which case you want to be testing for $wpmem_fields[$row][1]

  11. bk_design
    Member
    Posted 2 years ago #

    Hi Chad,

    I tried using $wpmem_fields[$row][1] and still no luck. I think I might have to deal with the form being the way that it is, currently I have 5 different titles to breakup the form. Even when I use the array to add a title it exports with the word "array" in the first row of the excel doc and when the form is submitted.

    For example if I have the first section title as "Accounting Information" it comes across in my submitted email as "Accounting Information: Array". See below for example from wp-members-install.php
    array ( 5, __('Accounting Information', 'wp-members'), '', '', 'y', 'n', 'n' ),
    I am not certain why the script is taking the word "Array" and using it as if it was filled in on the field.

  12. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    Brad,

    Could you contact me regarding this on the contact form at http://butlerblog.com. I can take a look at it, but you're probably going to need to provide me an admin login to look at a couple of things.

    -Chad

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic